"""ViewLayer URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import register_converter, path, re_path, include

from myapp import views
from . import converters

register_converter(converters.FourDigitYearConverter, 'yyyy')

urlpatterns = [
    path('admin/', admin.site.urls),
    # path('articles/<yyyy:year>/', views.year_archive)
    # re_path(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive)
    re_path(r'^blog/$', views.page),
    re_path(r'^blog/page(?P<num>[0-9]+)/$', views.page),
    path('myapp/', include('myapp.urls')),
    # re_path(r'^credit/', include(extra_patterns)),
    # re_path(r'^help/', include('myapp.urls')),
    # re_path(r'comments/(?:page-(?P<page_number>\d+)/)?$', comments),  # good
    # re_path(r'^blog/(?P<year>[0-9]{4})/$', views.year_archive, {'foo': 'bar'}),
]

extra_patterns = [
    re_path(r'^reports/$', views.page),
]

# urlpatterns = [
#     url(r'^(?P<page_slug>[\w-]+)-(?P<page_id>\w+)/', include([
#         url(r'^history/$', views.history),
#         url(r'^edit/$', views.edit),
#         url(r'^discuss/$', views.discuss),
#         url(r'^permissions/$', views.permissions),
#     ])),
# ]

# 增加的条目
handler400 = views.bad_request
handler403 = views.permission_denied
handler404 = views.page_not_found
handler500 = views.page_error
